<html>
<head><meta charset="utf-8"><title>Span of the Mutability · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Span.20of.20the.20Mutability.html">Span of the Mutability</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214773127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Span%20of%20the%20Mutability/near/214773127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> WhizSid <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Span.20of.20the.20Mutability.html#214773127">(Oct 27 2020 at 22:32)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> I am from the <a href="https://github.com/rust-lang/rust/issues/78315">https://github.com/rust-lang/rust/issues/78315</a> . Why <code>Mutability</code> is not taking a <code>Span</code>? I am working on <a href="https://github.com/rust-lang/rustfmt/pull/4482">https://github.com/rust-lang/rustfmt/pull/4482</a> and I want to check comments between <code>mut</code> keyword.</p>



<a name="214773295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Span%20of%20the%20Mutability/near/214773295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Span.20of.20the.20Mutability.html#214773295">(Oct 27 2020 at 22:34)</a>:</h4>
<p>I'm not the person to ask - maybe <span class="user-mention" data-user-id="133169">@matklad</span> or <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> have ideas for adding spans to keywords? (or just an existing way to do this)</p>



<a name="214773315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Span%20of%20the%20Mutability/near/214773315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Span.20of.20the.20Mutability.html#214773315">(Oct 27 2020 at 22:34)</a>:</h4>
<p>this is <code>rustc_ast::Mutability</code></p>



<a name="214773941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Span%20of%20the%20Mutability/near/214773941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Span.20of.20the.20Mutability.html#214773941">(Oct 27 2020 at 22:42)</a>:</h4>
<p>Spans are not free and are not assigned random AST nodes without a good reason.<br>
(Different reviewers may disagree on what a "good reason" is, though.)</p>
<p>So far the compiler got away without keeping the mutability span.<br>
It would be an optimal solution if rustfmt could extract the necessary span from codemap instead of adding it to rustc, which doesn't need it.<br>
I'm pretty sure rustfmt already extracts some spans this way, so there should be examples to follow.</p>



<a name="214775020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Span%20of%20the%20Mutability/near/214775020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> WhizSid <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Span.20of.20the.20Mutability.html#214775020">(Oct 27 2020 at 22:56)</a>:</h4>
<p>Yes there are some methods exist in rustfmt. And currently I am using a one of these.  But I felt like it is a non-idiomatic way. So I asked. Never mind.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>